package be.bonamis.common.data;

/**
 * Enum that represents languages.
 * 
 * @author FBonamis
 */
public enum Language {
	FR("fr"), NL("nl"), DE("de"), EN("en");

	private final String languageValue;

	/**
	 * Default Constructor.
	 * 
	 * @param langugageValue
	 */
	private Language(final String langugageValue) {
		this.languageValue = langugageValue;
	}

	/**
	 * Return the value of the Enum.
	 * 
	 * @return value as {@link String}
	 */
	public String languageValue() {
		return this.languageValue;
	}

	/**
	 * 
	 * @param value
	 * @return the language as {@link Language}
	 */
	public static Language languageOf(final String value) {
		for (Language language : Language.values()) {
			if (language.languageValue.equalsIgnoreCase(value)) {
				return language;
			}
		}
		throw new IllegalArgumentException("Language [" + value + "] not valid.");
	}
}